//index.js
//获取应用实例
const app = getApp()
Page({
  data: {
    hidden: true,
    userName: ""
  },
  cancel: function() {
    this.setData({
      hidden: true
    })
  },
  confirm: function() {
    const that = this
    wx.getUserInfo({
      success: function(res) {
        const userInfo = res.userInfo
        that.setData({
          hidden: true,
          userName: userInfo.nickName
        })
      }
    })
  },
  onLoad: function() {
    const that = this
    wx.getSetting({
      success: function(res) {
        if (!res.authSetting) {
          that.setData({
            hidden: false
          })
        }
      }
    })
  }
})